package com.etocrm.saas.lib.base.feign.codec.decode;

import com.etocrm.saas.lib.base.common.exception.FeignErrorException;
import com.etocrm.saas.lib.base.common.result.ResultCodeEnum;
import feign.Response;
import feign.codec.ErrorDecoder;
import lombok.extern.slf4j.Slf4j;

/**
 * Created by Xs on 2022/11/24.
 */
@Slf4j
public class SaasFeignErrorDecoder implements ErrorDecoder {

    @Override
    public Exception decode(String methodKey, Response response) {
        log.error("feign 远程调用异常 ......  异常方法 : {}, 异常code : {} , 异常原因 : {}", methodKey, response.status(), response.reason());
        throw new FeignErrorException(ResultCodeEnum.FEIGN_CALL_ERROR);
    }
}
